/**
* 
* created 31 March 2014 by jkl
* 
*/
package ecop017;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Shape;
import javax.swing.JPanel;

public class EcoZone {

    protected        String  myLabel;
    protected        Point   labelLocation;
    protected        int     lblX, lblY;
    protected        Color   myFill;
    protected        Shape   myShape;
    protected static Color   labelColor = Color.BLACK;
    protected        boolean init       = false;

    protected EcoZone(String label, Shape shape, Color color) {
        myLabel  = label;
        myShape  = shape;
        myFill   = color;

        // compute label offset
        lblX = (int)((
              myShape.getBounds().getWidth() - 
              Ecopia.fontMetrics.getStringBounds(label, null).getWidth())/2 +
              myShape.getBounds().getX());
        
        lblY = (int)((
              myShape.getBounds().getHeight() - 
              Ecopia.fontMetrics.getStringBounds(label, null).getHeight())/2 +
              myShape.getBounds().getY() +
              Ecopia.fontMetrics.getAscent());
    }
    
    protected EcoZone(String label, int[] coord, Color c){
        this(label,
             new Rectangle(coord[0],coord[1],coord[2],coord[3]),
             c);
    }

    // not currently used, left here just in case
    public void paint(Graphics2D g) {
      paintBG(g);
      paintLabels(g);
    }

    // paint graphics without text
    public void paintBG(Graphics2D g) {
      g.setColor(myFill);
      g.fill(myShape);
    }

    // so we can paint the labels on top of other graphic elements
    public void paintLabels(Graphics2D g) {
      g.setColor(labelColor);
      g.setFont(Ecopia.myFont);
      g.drawString(myLabel,lblX,lblY);
    }
    
}
